﻿using System;

namespace _6
{
    /// <summary>
    /// 四舍五入
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入一个正数");
         
            Double number = 0;
            while (true)
            {
                
                try
                {
                    number = Convert.ToDouble(Console.ReadLine());
                    if (number < 0)
                    {
                        Console.WriteLine("输入错误，请重新输入");
                        number = Convert.ToDouble(Console.ReadLine());
                    }
                    break;
                }
                catch
                {
                    Console.WriteLine("输入错误，请重新输入");
                    number = Convert.ToDouble(Console.ReadLine());
                }
            }
           
            int num = Convert.ToInt32(number);
            
            number = number - num;
            if (number > 0.5)
            {
                number = num + 1;
            }
            else
            {
                number = num;
            }
            Console.WriteLine("四舍五入后的结果为{0}", number);
            Console.ReadKey();
        }
    }
}